# Install required softwares
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -y --force-yes install ethtool
sudo apt-get -y --force-yes install iperf
sudo apt-get -y --force-yes install iperf3
sudo apt-get -y --force-yes install libpcap-dev

# Install tcpdump
cd /home/sr6/srv6_lib/tcpdump-master/
./configure
sudo make && make install && cd ..


# Enable IPv4 forwarding
sudo sysctl -w net.ipv4.conf.all.forwarding=1
# Enable IPv6 forwarding
sudo sysctl -w net.ipv6.conf.all.forwarding=1


# Instal srext
cd /home/sr6/srv6_lib/SRv6-net-prog-master/srext/
sudo make && sudo make install && sudo depmod -a && sudo modprobe srext


# Install Quagga
sudo apt-get update
sudo apt-get install autoconf automake libtool gawk texinfo libreadline6-dev -y
cd /home/sr6/srv6_lib/quagga-0.99.23/
autoreconf -ivf
sudo chmod 777 /home/sr6/srv6_lib/quagga-0.99.23/configure
./configure --enable-vtysh --enable-user=root --enable-group=root --localstatedir=/var/run/quagga --sysconfdir=/etc/quagga 
sudo make && sudo make install
# Copy shared library
sudo cp -r /usr/local/lib /lib


# Configure port
sudo su
cat>>/etc/services<<EOF
zebrasrv 2600/tcp # zebra service
zebra 2601/tcp # zebra vty
ripd 2602/tcp # RIPd vty
ripngd 2603/tcp # RIPngd vty
ospfd 2604/tcp # OSPFd vty
bgpd 2605/tcp # BGPd vty
ospf6d 2606/tcp # OSPF6d vty
ospfapi 2607/tcp # ospfapi
isisd 2608/tcp # ISISd vty
pimd 2611/tcp # PIMd vty
nhrpd 2612/tcp # nhrpd vty
EOF


# Allowed daemons
touch /etc/quagga/daemons
cat>>/etc/quagga/daemons<<EOF
zebra=yes
bgpd=yes
ospfd=no
ospf6d=no
ripd=no
ripngd=no
isisd=no
EOF


# Zebra & bgpd configuration file
cp /etc/quagga/zebra.conf.sample /etc/quagga/zebra.conf
cp /etc/quagga/bgpd.conf.sample /etc/quagga/bgpd.conf


# Start Zebra & bgpd daemons
cp /usr/local/lib/libzebra.* /lib
mkdir /var/run/quagga
zebra -d
bgpd -d
# vtysh


exit